package com.tvshows.structure.beans;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.ForeignKey;
import org.hibernate.annotations.GenericGenerator;

@Entity( name = "Historique" )
@NamedQueries( { @NamedQuery( name = "historique.byShow", query = "SELECT h from Historique h where h.favorite=:favorite and h.addDate <> :today" ) } )
public class Historique
{

    @Id
    @Column( name = "ID" )
    @GenericGenerator( name = "gen", strategy = "increment" )
    @GeneratedValue( generator = "gen" )
    private int id;

    @Column( name = "Date", nullable = false )
    @Temporal( TemporalType.TIMESTAMP )
    private Date addDate;

    @ManyToOne( fetch = FetchType.LAZY )
    @ForeignKey( name = "FAVORITE_ID" )
    private Favorite favorite;

    public int getId()
    {
        return id;
    }

    public void setId( int id )
    {
        this.id = id;
    }

    public Date getAddDate()
    {
        return addDate;
    }

    public void setAddDate( Date addDate )
    {
        this.addDate = addDate;
    }

    public Favorite getFavorite()
    {
        return favorite;
    }

    public void setFavorite( Favorite favorite )
    {
        this.favorite = favorite;
    }


}
